﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Vibz.Common.Channel
{
    public class SocketPacket
    {
        public System.Net.Sockets.Socket Socket { get; set; }
        public byte[] DataBuffer { get; set; }

        public SocketPacket(System.Net.Sockets.Socket socket)
        {
            Socket = socket;
            DataBuffer = new byte[512000];
        }
        public string GetData(IAsyncResult asyn)
        {
            if (!this.Socket.Connected)
                return null;

            int numberOfBytesReceived = this.Socket.EndReceive(asyn);
            if (numberOfBytesReceived == 0)
                return null;

            return Encoding.ASCII.GetString(this.DataBuffer, 0, numberOfBytesReceived).Trim();
        }
    }
}